<template>
  <div>
    <!-- 主体部分 -->
    <section class="main">
      <input id="toggle-all" class="toggle-all" type="checkbox" />
      <label for="toggle-all" @click="allchoice">Mark all as complete</label>
      <ul class="todo-list">
        <li
          :class="{ completed: item.flag }"
          v-for="item in todolist"
          :key="item.id"
        >
          <div class="view">
            <input
              class="toggle"
              type="checkbox"
              @change="changethisBtn(item.id, $event)"
              :checked="item.flag"
            />
            <label>{{ item.value }}</label>
            <button class="destroy" @click="dellist(item.value)"></button>
          </div>
        </li>
      </ul>
    </section>
  </div>
</template>

<script>
export default {
  name: 'TodoMain',
  components: {},
  props: {
    todolist: {
      type: Array,
      required: true,
    },
  },
  data() {
    return {}
  },
  computed: {},
  watch: {},
  methods: {
    changethisBtn(id, e) {
      this.$emit('changethisBtn', id, e.target.checked)
    },
    //删除
    dellist(value) {
      this.$emit('dellist', value)
    },
    //全选
    allchoice() {
      this.flag = !this.flag
      this.$emit('allchoice', this.flag)
    },
  },
}
</script>

<style scoped></style>
